﻿<%@ Page Language="C#" AutoEventWireup="true"
    Inherits="website_admin_members_shippingaddresseditor" Codebehind="shippingaddresseditor.aspx.cs" %>

<%@ Register Src="../../admin/_root/_controls/ctlNavBar.ascx" TagName="ctlNavBar"
    TagPrefix="uc1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <title></title>

    <script type="text/javascript" src="../_static/_jQuery/jquery-1.3.2.min.js"></script>

    <script type="text/javascript" src="../../admin/_static/_jQuery/jquery_validator.js"></script>

    <script type="text/javascript" language="javascript" src="../_common/scripts/util.js"></script>

    <script language="javascript" src="../_static/_jQuery/jquery-fileupload.js" type="text/javascript"></script>

    <script language="javascript" src="../_static/_jQuery/jquery_json.js" type="text/javascript"></script>

    <script language="javascript" src="../_static/_jQuery/jquery_stringutil.js" type="text/javascript"></script>

    <script language="javascript" src="../_static/_jQuery/interface.js" type="text/javascript"></script>

    <link href="../_common/styles/frame_global.css" rel="stylesheet" type="text/css" />

    <script language="javascript" src="../../_common/datepicker/wdatepicker.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
    $(document).ready(setup);
    function setup()
    {
        validator.setup("#crmForm");
        
        $("#txtShippingAddressId").val(getUrlParam("shippingaddressid"));
        /// 初始化编辑内容
        GetAddressContentEditInfo();
        /// 绑定当前关联地址
        $("#selShippingAddressList").val($("#txtShippingAddressId").val());
        /// 加载地区选择列表
        if($("#txtProvinceId").val() != "")
            $("#selProvinceList").val($("#txtProvinceId").val());
        LoadRegionList('init', 'province', 1);
        LoadRegionList('init', 'city', 2);
        LoadRegionList('init', 'countie', 3);
    }
    /// 送货地址——初始化编辑内容
    function GetAddressContentEditInfo()
    {
        var _values = InitializeAddressObj(); 
        $(_values).find("filed").each(function(){
            if($("#txt"+$(this).attr("name")))
                $("#txt"+$(this).attr("name")).val($(this).text());
        })
    }
    /// 送货地址——匹配ID初始化数据
    function InitializeAddressObj()
    {
        var values = null;
        $.ajax({
            async: false,
            type: "POST",
            url:  prependOrgName("/website_admin/members/shippingaddresseditor.aspx"),
            data: {
                otype:                    "getaddressobj",
                txtShippingAddressId:     $("#txtShippingAddressId").val()
            },
            success: function(data, textStatus) { 
                values = data; 
            }
        });
        return values;
    }
    function Cancel()
    {
        var groupid=getUrlParam("groupid");
        window.location.href="shippingaddresslist.aspx?groupid="+groupid;
    }
    function LoadRegionList(loadingtype, layername, _layer)
    {
        var _parentid = "";
        if(layername == "province")
            _parentid = "0";   
        if(layername == "city")
            _parentid = $("#selProvinceList").val(); 
        if(layername == "countie")
            _parentid = $("#selCityList").val();
            
        if(_parentid != "")
        {
            $.ajax({
                async   :   false,
                type    :   "POST",
                url     :   prependOrgName("/website_admin/members/shippingaddresseditor.aspx"),
                data    :   { otype : "getregionlist", layer: _layer, parentid : _parentid },
                success :   function(data, textStatus) {
                    switch(_layer)
                    {
                        case 1:
                            $("#selProvinceList").emptySelect().append(data).change(function() {
                                $("#txtProvinceId").val($("#selProvinceList").val());
                                $("#txtCityId").val($("#selCityList").val()); 
                                LoadRegionList("event", "city", 2);
                                LoadRegionList("event", "countie", 3);
                            });
                            break;
                        case 2:
                            $("#selCityList").emptySelect().append(data).change(function() {
                                $("#txtCityId").val($("#selCityList").val()); 
                                LoadRegionList("event", "countie", 3); 
                            });
                            break;
                        case 3:
                            $("#selCountiesList").emptySelect().append(data).change(function() { 
                                $("#txtCountieId").val($("#selCountiesList").val()); 
                            }); 
                            break;
                    }
                }
            });

            if(loadingtype == "init")
            {
                if($("#txtProvinceId").val() != "")
                    $("#selProvinceList").val($("#txtProvinceId").val());
                if($("#txtCountieId").val() != "")
                    $("#selCountiesList").val($("#txtCountieId").val());
                if($("#txtCityId").val() != "")
                    $("#selCityList").val($("#txtCityId").val());
            }
        }
        else
        {
            if($("#txtProvinceId").val() == "")
            {
                $("#selCityList").emptySelect().append("<option value=''>-- 请选择城市 --</option>");
                $("#txtProvinceId").val("");
                $("#txtCityId").val("");
                $("#txtCountieId").val("");
            }
            if($("#txtCityId").val() == "")
            {
                $("#selCountiesList").emptySelect().append("<option value=''>-- 请选择区县 --</option>");
                $("#txtCityId").val("");
                $("#txtCountieId").val("");
            }
        }
    }
    function LoadFunctionDataList()
	{
	    
	}
    </script>

</head>
<body> 
    <form id="crmForm" runat="server">
    <input type="hidden" name="___EVENTTARGET" id="___EVENTTARGET" value="" />
    <input id="txtProvinceId" type="hidden" name="txtProvinceId" />
    <input id="txtCityId" type="hidden" name="txtCityId" />
    <input id="txtCountieId" type="hidden" name="txtCountieId" />
    <input id="txtShippingAddressId" type="hidden" name="txtShippingAddressId" />
    <div class="divAreas">
        <div class="boxTopBar">
            <div class="boxTopBarLeft">
                <div class="navBar">
                    <uc1:ctlNavBar ID="ctlNavBar1" runat="server" />
                </div>
            </div>
            <div class="boxTopBarRight">
            </div>
        </div>
        <div class="boxMain">
            <div class="boxMainBody">
                <table cellpadding="0" cellspacing="0" class="stdTable" style="width: 98%;">
                    <tbody>
                        <tr style="height: 32px; background: #F0F0F0; padding-left: 10px; font-weight: bold;
                            text-align: left;">
                            <td>
                                编辑会员信息
                            </td>
                        </tr>
                        <tr>
                            <td valign="top" style="padding: 5px 5px 5px;">
                                <div style="overflow-y: scroll; overflow-x: hidden; height: 320px; margin-left: auto;
                                    margin-right: auto; padding: 10px 20px 10px 20px; width: auto;">
                                    <div class="checkoutBox noBorder" id="shippingAddressContentEditPanel">
                                        <ul class="infoList edit" id="shippingAddressEditContentInfo">
                                            <li id="firstLine">
                                                <label for="txtShipToName">
                                                    地址类型：</label>
                                                <input class="tbxReadOnly" name="txtShipAddressName" type="text" id="txtShipAddressName" validatormsg="spanShipAddressName"
                                                    value="我的地址1" required="required" controlname="地址类型" isvalidator style="width: 200px;" />
                                                <span class="alertPanel" id="spanShipAddressName"></span></li>
                                            <li>
                                                <label for="txtShipToName">
                                                    收货联系人：</label>
                                                <input class="tbxReadOnly" name="txtShipToName" type="text" id="txtShipToName" validatormsg="spanShipToName"
                                                    required="required" controlname="收货联系人" isvalidator style="width: 200px;" />
                                                <span class="alertPanel" id="spanShipToName"></span></li>
                                            <li>
                                                <label for="txtMobile">
                                                    手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机：</label>
                                                <input class="tbxReadOnly" name="txtShipMobile" type="text" id="txtShipMobile" style="width: 200px;" />
                                                </li>
                                            <li>
                                                <label for="txtShipTel">
                                                    联系电话：</label>
                                                <input class="tbxReadOnly" name="txtShipTel" type="text" id="txtShipTel" required="required" controlname="联系电话"
                                                    isvalidator validatormsg="spanShipTel" style="width: 150px;" />
                                                <span class="alertPanel" id="spanShipTel"></span></li>
                                            <li>
                                                <label for="selProvinceList">
                                                    地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;区：</label>
                                                <select id="selProvinceList" name="selProvinceList" class="SelectBox" style="width: 100px;">
                                                </select>
                                                <select id="selCityList" name="selCityList" class="SelectBox" style="width: 120px;">
                                                    <option value="">-- 选择城市 --</option>
                                                </select>
                                                <select id="selCountiesList" name="selCountiesList" class="SelectBox" style="width: 120px;">
                                                    <option value="">-- 选择区县 --</option>
                                                </select>
                                                <span class="alertPanel" id="spanCountiesList"></span></li>
                                            <li>
                                                <label for="txtShipAddress">
                                                    联系地址：</label>
                                                <input class="tbxReadOnly" name="txtShipAddress" type="text" id="txtShipAddress" required="required"
                                                    controlname="联系地址" isvalidator validatormsg="spanShipAddress" style="width: 350px;" />
                                                <span class="alertPanel" id="spanShipAddress"></span></li>
                                            <li>
                                                <label for="txtShipZip">
                                                    邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;编：</label>
                                                <input class="tbxReadOnly" name="txtShipZip" type="text" id="txtShipZip" style="width: 200px;" />
                                            </li>
                                            <li></li>
                                        </ul>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <tr style="height: 35px;">
                            <td class="WIN-Form-Bottom"> 
                                <input type="button" value="返回列表" id="btnCancel" class="btn_s" onclick="Cancel();"
                                    style="height: 25px; width: 120px; margin: 0px 5px;" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="boxBottomBar">
            <div class="boxBottomBarLeft">
                &nbsp;
            </div>
            <div class="boxBottomBarRight">
                &nbsp;
            </div>
        </div>
    </div>
    </form>
</body>
</html>
